package com.gcd.alienandwheel.stage;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.actions.Delay;
import com.badlogic.gdx.scenes.scene2d.actions.FadeOut;
import com.badlogic.gdx.scenes.scene2d.actors.Image;
import com.gcd.alienandwheel.MyGame;
import com.gcd.alienandwheel.MyUtil;

/**
 *
 * @author Rezan Achmad
 */
public class PreLoad extends MyStage{

    Image image;
    float temp = 0;
    float durationFadeOut = 1.5f;
    float durationShow = 2;
    

    public PreLoad(MyGame myGame, float width, float height, boolean stretch) {
        super(myGame, width, height, stretch);
        init();
    }

    private void init() {        
        image = new Image("splah", new Texture(MyUtil.loadImage("logo-compfest.png")));
        image.x = (width - image.width) / 2;
        image.y = (height - image.height) / 2;
        image.action(Delay.$(FadeOut.$(durationFadeOut), durationShow));
        addActor(image);
    }

    @Override
    public void act(float delta) {
        super.act(delta);
        
        temp += delta;        
        if (temp > durationFadeOut + durationShow) {
            myGame.setStage(new Home(myGame, width, height, stretch));
        }
    }

    @Override
    public void draw() {        
        super.draw();
    }
}